<form name="form_admin" method="POST" action="" >
<input type="hidden" name="opt" value="save" />
<table border="0" width="100%" cellpadding="0" cellspacing="0">
   <tr>
		<td height="20"></td>
	</tr>
    <tr>
        <td width="100"><b>Category</b></td>
        <td>
        <select name="Category" id="Category" onchange="location='?module=customtourmap&opt=customfield&&cat='+this.value">
          	<?php echo option_customfield($category)?>
        </select>
        <textarea style="display:none"></textarea>
        </td>
    </tr>
    <tr>
    <td colspan="2">
		<table width="100%" cellpadding="4" cellspacing="1"id="tblsort">
			<tr class="headtb" nodrop="true" nodrag="true">
				<td width="5%" >Order</td>
				<td width="60%" >Value</td>				
				<td >Select</td>
			
			</tr>	
		</table>
		<input type="button" class="b1" value="Add row" onclick="addfield()">
			<input type="button" onclick="location.reload(true)" class="b1"  value="Reset"> 
    </td>
    </tr>
</table>
</form>
<script>
var isPrice=<?echo ($filter['cValue']=="Price")? "true": "false"?>;
function changetype(cb)
{
	if(cb.checked)isPrice=true;
	else isPrice=false;
	
	tblroot=getId("tblsort").tBodies[0];
	rows=tblroot.rows;
	for(i=rows.length-1;i>0;i--)
	{
		tblroot.removeChild(rows[i]);
	}
	orderrow=0;
	for(i=0;i<5;i++)
	{
		addfield();
	}
}

var orderrow=0;
function addfield(iddl,dl1,dl2)
{	
	tblroot=getId("tblsort").tBodies[0];
	var newtr=document.createElement("tr");
	newtr.className='row_'+(orderrow%2);
	var newtd=document.createElement("td");
	var input1=document.createElement("input");
	input1.className="ordertext";
	input1.id="listorder_"+orderrow;
	input1.name="listorder[]";
	input1.value=orderrow+1;
	newtd.appendChild(input1);
	newtr.appendChild(newtd);
	
	newtd=document.createElement("td");	
	newtr.appendChild(newtd);
	var in1=document.createElement("input");
	in1.name="listvalue1[]";
	in1.className='normal01';
    if(dl1!=undefined)in1.value = dl1;
	newtd.appendChild(in1);	
	var in2=document.createElement("input");
	in2.name="listid[]";
	in2.setAttribute("type","hidden");
	if(iddl!=undefined)in2.value=iddl;
	newtd.appendChild(in2);	
	
	newtd=document.createElement("td");
    var newa=document.createElement("a");
	newa.innerHTML="delete";
	newa.style.cursor="pointer";
	newa.onclick=function()
	{
	   newtr.style.display='none';
       in1.value=-1;
	};
	newtd.appendChild(newa);
	newtr.appendChild(newtd);
	
	tblroot.appendChild(newtr);
	orderrow++;
	(new TableDnD).init("tblsort");	
}
<?
foreach($listfields as $i=> $f)
{
	echo ';addfield("'.$f['iId'].'","'.$f['cName'].'","'.$value2.'");';
}
?>
</script>